<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Authentification
 *
 * @author admin
 */
class Authentification {

    function __construct() {
        $db = mysql_connect("localhost", "root", "root");
        mysql_selectdb("projet2", $db);
        session_name('SESSION1');
        session_start();
    }

    public function Auth() {

        if (isset($_POST['login']) && isset($_POST['motdepasse'])) {



            $login = $_POST['login'];
            $motdepasse = $_POST['motdepasse'];

            $sql1 = "select login,motdepasse from administrateur";
            $sql2 = "select login,motdepasse from collaborateur where login='$login'";
            $sql3 = "select login,motdepasse from manager where login='$login'";

            $req1 = mysql_query($sql1);
            $req2 = mysql_query($sql2);
            $req3 = mysql_query($sql3);

            $data1 = mysql_fetch_array($req1);
            $data2 = mysql_fetch_array($req2);
            $data3 = mysql_fetch_array($req3);

            if (($data1['login'] == $login) && ($data1['motdepasse'] == $motdepasse)) { 
                header('Location: MenuAdmin.html');
            } elseif (($data2['login'] == $login) && ($data2['motdepasse'] == $motdepasse)) {
                $sql10 = mysql_query("update test set logincol='$login' where nom='logincol'");
                header('Location: tachescollaborateur.php');
            } elseif (($data3['login'] == $login) && ($data3['motdepasse'] == $motdepasse)) {
                $_SESSION['login'] = $_POST['login'];
                header('Location: menumanager.php');
            } else {
                echo "<center><font color='white'>vérifier vos  coordonnées</font></center>";
            }
        }
    }

}

?>
